.Dd $Mdocdate$
.Dt DSBMC-Cli 1
.Os
.Sh ABOUT
.Nm dsbmc-cli
is a command-line client for DSBMD that provides a simple interface
to query information about storage devices, and to send requests to
mount, unmount and eject these.
.Sh INSTALLATION
.Bd -literal
# git clone https://github.com/mrclksr/DSBMC-Cli.git
# git clone https://github.com/mrclksr/libdsbmc.git
# cd DSBMC-Cli && make install
.Ed
.Sh USAGE
.Nm
.Fl L Ar event Ar command
.Op Ar arg ...
\;
.Op Fl L Ar ...
.br
.Nm
.Fl a
.Op Fl b Ar dev1,dev2,...
.Bo
.Fl U Ar time
.Bc
.Bo
.Op Fl L Ar event Ar command Op Ar arg ...
\;
.Op Fl L Ar ...
.Bc
.br
.Nm
.Brq Bro Fl e | u Brc Bo Fl f Bc | Bro Fl m | s | u | v Ar speed Brc
.Ar device
.br
.Nm
.Brq Fl e | u
.Ar "<mount point>"
.br
.Nm
.Fl i
.Ar "<disk image>"
.br
.Nm
.Fl l
.br
.Nm
.Op Fl h
.Pp
.Sh OPTIONS
.Bl -tag -width indent
.It Fl L
Listen for
.Ar event ,
and execute the
.Ar command
every time the
.Em event
is received. Possible events are
.Em mount ,
.Em unmount ,
.Em add ,
and
.Em remove .
The
.Ar command
must be terminated by a semicolon
.Pq Sq \;
as a separate argument. Each event provides information about the device
that can be accessed using the placeholders
.Em %d
(device name),
.Em %l
(volume label),
.Em %m
(mount point) (only
.Em mount
and
.Em unmount
), and
.Em %t
(device type). A literal percent character
.Pq Sq %
must be escaped by a further
.Sq %
character
.Pq Dq %% .
Possible values for the device type
.Pq Em %t
are
.Em hdd , usbdisk , datacd , audiocd , dvd , vcd ,  svcd ,  mmc , mtp ,
and
.Em ptp .
The
.Fl L
option can be given multiple times.
.It Fl U
Auto-unmount. Try to unmount each automounted device every
.Sq Ar time
seconds.
.It Fl a
Automount. After mounting all devices presented by DSBMD,
.Xr dsbmc-cli 1
waits for new devices added to the system, and mounts them.
In addition, the
.Fl L
option can be specified for each event. If
.Xr dsbmc-cli 1
automounts a device, it executes the command defined for the
.Em mount
event.
.It Fl b Ar dev1,dev2,...
Define a comma-separated list of devices and/or volume labels to ignore if the
.Fl a
option is given. Volume labels must be prefixed by
.Dq volid= .
.br
Example: dsbmc-cli -a -b da0p2,volid=EFISYS,volid=TMP
.It Fl e Ar device , Fl e Ar <mount point>
Eject the given
.Ar device
or the device mounted on
.Ar <mount point>
.It Fl i Ar <disk image>
Create a memory disk to access the given
.Ar disk image .
.It Fl l
List all currently attached devices DSBMD supports.
.It Fl m Ar device
Mount the given
.Ar device .
.It Fl s Ar device
The storage capacity of the given
.Ar device
is queried, and the media size, the number of used and free bytes are
printed to stdout.
.It Fl u Ar device , Fl u Ar <mount point>
Unmount the given
.Ar device
or the device mounted on
.Ar <mount point>
.It Fl v Ar speed Ar device
Set the reading speed of the given CD/DVD
.Ar device .
.El
.Sh EXAMPLES
.Ss Automounting
Just execute
.Sq dsbmc-cli -a
or, if you wish, add the command
.Sq dsbmc-cli -a 2>/dev/null&
to your shell's startup file, your display
manager's startup file, or your
.Em ~/.xsession .
If you don't want to manually unmount your devices, you can in addition use
the
.Fl U
flag.
.Ss Events
.Dl $ dsbmc-cli -L mount printf \(dq%%s was mounted on %%s\en\(dq %d %m ';'

This command listens for
.Em mount
events, and executes the
.Em printf
command, where %d and %m are replaced by the device name and mount point.

.Dl $ dsbmc-cli -a -L add sh -c 'case %t in audiocd) vlc cdda://%d&;; dvd) vlc dvd://%d&;; esac' ';' -L mount sh -c 'Thunar %m&' ';'

In this example,
.Nm
automounts devices, and listens for
.Ar add
and
.Ar mount
events. If an audio CD or a DVD was inserted, the command
.Em "vlc cdda://%d&"
or
.Em "vlc dvd://%d&"
is executed, respectively. If a device was mounted,
.Nm
executes the command
.Em "Thunar %m&",
where %m is replaced by the mount point.

